package com.wh.wisdomsite.xbox.client.service.zywl;

import com.alibaba.fastjson.JSONObject;
import com.wh.wisdomsite.xbox.common.Constants;
import com.wh.wisdomsite.xbox.common.annotation.NeedInSessionType;
import com.wh.wisdomsite.xbox.common.annotation.ServiceMethod;
import com.wh.wisdomsite.xbox.common.annotation.ServiceProvider;
import com.wh.wisdomsite.xbox.common.reponse.CommonResult;
import com.wh.wisdomsite.xbox.pojo.zywl.GetUpdateMessageIn;
import com.wh.wisdomsite.xbox.utils.Const;
import com.wh.wisdomsite.xbox.utils.server.connToserver_HttpClientClose;
import com.wh.wisdomsite.xbox.zywl.service.IZywlGateGroupService;
import com.wh.wisdomsite.xbox.zywl.service.IZywlGateService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 遵义微乐闸机接口 Service
 * @author 丁奕
 * @version V1.0
 * @Package com.wh.wisdomsite.xbox.client.service.zywl
 * @date 2019年2月21日 9:52
 * @Copyright 企业版权所有
 * @Company 贵州万华科技有限公司Copyright (c) 2018
 */
@ServiceProvider()
public class ZywlGateInfoService {

    private static final Log logger = LogFactory.getLog(ZywlGateInfoService.class);

    @Autowired
    private IZywlGateService zywlGateService;

    @Autowired
    private IZywlGateGroupService zywlGateGroupService;

    /**
     * 接收更新闸机信息通知
     * @param in
     * @return
     */
    @ServiceMethod(method = "zywl.gate.getUpdateMessage", title = "接收闸机更新通知", version = "1.0", needInSession = NeedInSessionType.NO)
    public CommonResult getUpdateMessage(GetUpdateMessageIn in){
        CommonResult commonResult = new CommonResult();
        try{
            logger.info("接收闸机更新通知->>zywl.gate.getUpdateMessage->>开始");
            //调用同步闸机信息的方法
            commonResult = zywlGateGroupService.sycGateInfo();
            logger.info("接收闸机更新通知信息->>zywl.gate.getUpdateMessage->>结束");
        } catch (Exception e){
            e.printStackTrace();
            commonResult.setCode(Constants.CODE_FAIL);
            commonResult.setMessage("接收闸机更新通知信息异常");
            in.getXboxRequestContext().setException(new Exception(e.getMessage()));
            logger.error("接收闸机更新通知信息->>zywl.gate.getUpdateMessage->>异常："+e.getMessage());
        }
        return commonResult;
    }
}
